package com.example.myhttplibrary.callback;

import com.example.myhttplibrary.exceptiopn.ApiException;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public abstract class BaseObserver implements Observer {
    @Override
    public void onSubscribe(Disposable d) {

    }



    @Override
    public void onError(Throwable e) {
        if (e instanceof ApiException){
            ApiException apiException= (ApiException) e;
            error(apiException.getMsg(),apiException.getCode());
        }
    }

    @Override
    public void onComplete() {

    }

    protected  abstract void error(String error,int code);
}
